package com.cuit.blogsystem.service.Impl;

import com.cuit.blogsystem.DTO.CommentPageQueryDTO;
import com.cuit.blogsystem.Result.PageResult;
import com.cuit.blogsystem.VO.CommentVO;
import com.cuit.blogsystem.mapper.CommentMapper;
import com.cuit.blogsystem.service.CommentService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    /**
     * 分页查询评论
     * @param commentPageQueryDTO
     * @return
     */
    @Override
    public PageResult pageQuerry(CommentPageQueryDTO commentPageQueryDTO) {
        PageHelper.startPage(commentPageQueryDTO.getPage(), commentPageQueryDTO.getPageSize());
        Page<CommentVO> commentPage = commentMapper.pageQuery(commentPageQueryDTO);
        return new PageResult(commentPage.getTotal(), commentPage.getResult());
    }
}
